package com.xinruke.hostels.central.manage.controller;

import com.xinruke.hostels.central.manage.interfaces.dto.sensitiveword.*;
import com.xinruke.hostels.central.manage.service.SensitiveWordService;
import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * @author yutaipu
 */
@RestController
@RequestMapping(value = "/sensitive-word")
@Api(tags = "敏感词")
@Slf4j
public class SensitiveWordController extends BaseController {
    
    @Autowired
    private SensitiveWordService sensitiveWordService;

    @PostMapping(value = "/add")
    @ApiOperation("添加")
    public ResultVO add(@RequestBody @Valid SensitiveWordAddDTO params){
        return sensitiveWordService.add(params);
    }

    @PostMapping(value = "/modify")
    @ApiOperation("修改")
    public ResultVO modify(@RequestBody @Valid SensitiveWordModifyDTO params){
        return sensitiveWordService.modify(params);
    }

    @PostMapping(value = "/delete")
    @ApiOperation("删除")
    public ResultVO delete(@RequestBody @Valid SensitiveWordDeleteDTO params){
        return sensitiveWordService.delete(params);
    }

    @PostMapping(value = "/list")
    @ApiOperation(value = "查询敏感词列表")
    public ResultVO<RowsDataVO<SensitiveWordQueryResultDTO>> list(@Valid @RequestBody SensitiveWordQueryListDTO params) {
        return sensitiveWordService.list(params);
    }

    @PostMapping(value = "/detail")
    @ApiOperation(value = "查询敏感词详情")
    public ResultVO<SensitiveWordQueryResultDTO> detail(@Valid @RequestBody SensitiveWordDetailDTO params){
        return sensitiveWordService.detail(params);
    }
}
